using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.IsolatedStorage;
using System.Diagnostics;

namespace JumpyCat.bamboo
{
    class SaveHighScoreHelper
    {
        private static String storeName = "HightScore";

        public static int getHighScore()
        {
            var settings = IsolatedStorageSettings.ApplicationSettings;
            int hightScore = 0;
            if (settings.Contains(storeName))
            {
                string scoreStr = (string)settings[storeName];
                try
                {
                    hightScore = int.Parse(scoreStr);
                    return hightScore;
                }
                catch (System.Exception ex)
                {
                    Debug.WriteLine(ex.Message.ToString());
                }

            }

            return hightScore;

        }

        public static void saveHighScore(int score)
        {
            var settings = IsolatedStorageSettings.ApplicationSettings;

            if (settings.Contains(storeName))
            {
                settings[storeName] = score.ToString();
                settings.Save();

            }
            else
            {
                settings.Add(storeName, score.ToString());
                settings.Save();
            }

        }

    }
}
